Skip to contentMethod: computeNextMove(int, GDPlayer, GDState)
      1: package de.fhdw.gaming.ipspiel22.gefangenenDilemma.strategy;
2: 
3: import java.util.Optional;
4: 
5: import de.fhdw.gaming.ipspiel22.gefangenenDilemma.domain.GDPlayer;
6: import de.fhdw.gaming.ipspiel22.gefangenenDilemma.domain.GDState;
7: import de.fhdw.gaming.ipspiel22.gefangenenDilemma.domain.GDStrategy;
8: import de.fhdw.gaming.ipspiel22.gefangenenDilemma.moves.GDMove;
9: import de.fhdw.gaming.ipspiel22.gefangenenDilemma.moves.factory.GDMoveFactory;
10: 
11: /**
12:  * Implements {@link GDStrategy} by always making a statement.
13:  */
14: public class GDStatementStrategy implements GDStrategy {
15: 
16:     /**
17:      * The factory for creating Gefangenen Dilemma moves.
18:      */
19:     private final GDMoveFactory moveFactory;
20: 
21:     /**
22:      * Creates an {@link GDStatementStrategy}.
23:      *
24:      * @param moveFactory The factory for creating Gefangenen Dilemma moves.
25:      */
26:     public GDStatementStrategy(final GDMoveFactory moveFactory) {
27:         this.moveFactory = moveFactory;
28:     }
29: 
30:     @Override
31:     public Optional<GDMove> computeNextMove(final int gameId, final GDPlayer player, final GDState state) {
32:         return Optional.of(this.moveFactory.createStatementMove());
33:     }
34: 
35:     @Override
36:     public String toString() {
37:         return GDStatementStrategy.class.getSimpleName();
38:     }
39: }